﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;


namespace LaneLpnr.RWLPNRVideo
{
    public class RWLPNRVideoProgram
    {
        // DLL exported interface
        // 创建视频流解码对象，strIP是摄像机IP，stream取值[0..1] 分别为主码流和次码流
        // 如果需要更改视频流设置，使用RWLPNRAPI.lib/RWLPNRDLL.dll接口实现, 那个动态库是LPNRTool和摄像机交互的底层库，所有功能都支持的。
        // 返回的句柄为后续操作的第一个参数h。 返回NULL表示连接失败，或是参数错误(IP格式，stream取值范围)
        [DllImport("RWLPNRVideo.dll", EntryPoint = "VIDEO_Create", SetLastError = true, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
        public static extern IntPtr VIDEO_Create(string strIP, int stream);

        //释放所有资源，包括句柄本身
        [DllImport("RWLPNRVideo.dll", EntryPoint = "VIDEO_Terminate", SetLastError = true, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
        public static extern bool VIDEO_Terminate(IntPtr h);

        //设置视频解码后显示的窗口
        [DllImport("RWLPNRVideo.dll", EntryPoint = "VIDEO_SetRenderWindow", SetLastError = true, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
        public static extern bool VIDEO_SetRenderWindow(IntPtr h, IntPtr hWnd);

        // 显示控制 (暂停/开始) VIDEO_SetRenderWindow后必须调用 VIDEO_Start(h)才会开始显示， 中间可以随时调用Video_Stop暂停，再调Video_Start恢复
        [DllImport("RWLPNRVideo.dll", EntryPoint = "VIDEO_Start", SetLastError = true, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
        public static extern bool VIDEO_Start(IntPtr h);

        [DllImport("RWLPNRVideo.dll", EntryPoint = "VIDEO_Stop", SetLastError = true, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
        public static extern bool VIDEO_Stop(IntPtr h);

    }
}
